package demo2;

import java.lang.reflect.Constructor;

public class Test {
    /*
        运行下列代码 由此可以得出 Enum 不能被反射
     */
    public static void main(String[] args) throws Exception{
        Class<?> c = Class.forName("demo2.EnumDemo");
        Constructor<?> constructor = c.getDeclaredConstructor(String.class, int.class, int.class, String.class);
        constructor.setAccessible(true);
        EnumDemo enumDemo = (EnumDemo)constructor.newInstance("n", 1, 2,"2");
        System.out.println(enumDemo);
    }
}
